﻿@using System.Web.Optimization
@using Ed.Entity
@model dynamic
@{   
    Layout = null;
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>雪绒花_订单管理_待处理订单</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    @Styles.Render("~/Themes/default/css/cp.globle.min6.css")
    @Scripts.Render("~/Themes/default/js/cp.globle.min6.js")
        <!--去除顶层加载中 14-10-17 By 唐有炜-->
        <script type="text/javascript">
            //=============================================================
            //去除顶层加载中
            $(document).ready(function () {
                //去除加载中
                if (undefined != top.dialog.list["show_loading"]) {
                    top.dialog.list["show_loading"].close().remove();
                    //showTopMsg("页面加载成功！", "温馨提示", "Success");
                }
            });
            //=====================================================================
        </script>
        <script type="text/javascript">
            //全局变量
            var order_grid;

            $(function () {

                //初始化表格
                InitOrderGrid();
            });


            function InitOrderGrid() {              
                order_grid = $("#order_grid_data").bootgrid({
                    ajax: true,
                    post: function () {
                        return {
                            OrderStatus: 1,                       
                        };
                    },
                    url: "/api/OrderApi/GetBootGridOrders",
                    selection: true,
                    multiSelect: true,
                    rowSelect: false,
                    keepSelection: true,
                    rowCount: [10, 30, 50],
                    templates: {
                        header: "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\"><div class=\"col-sm-12 actionBar\"><div class=\"btn-group\" style=\"float:left;\"><button class=\"btn btn-default tip\" title=\"订单作废\" onclick=\"return order_trash(); \"><span class=\"glyphicon glyphicon glyphicon glyphicon-trash\"></span>作废订单</button></div>" +
                    "<div class=\"search form-group\"><div class=\"input-group\"><span class=\"icon glyphicon input-group-addon glyphicon-search\"></span> <input type=\"text\" class=\"search-field form-control\" placeholder=\"输入关键字\"></div></div>" +
                    "<p class=\"{{css.actions}}\"></p></div></div></div>"
                    },
                    labels: {
                        all: "all", //checkbox全选的值
                        search: "请输入名称",
                        loading: "加载中...",
                        noResults: "对不起，暂无符合条件的记录！",
                        refresh: "刷新",
                        infos: "从{{ctx.start}} 到 {{ctx.end}}，共{{ctx.total}} 条记录"
                    },
                    formatters: {
                        ClientId: function (colum, row) {
                            return row.ClientName + "<span style='color:green;font-weight:bold;margin-left:5px; font-size:13px;'>" + row.ClientTel1 + "</span>";
                        },
                        OrderStatus: function (colum, row) {
                            switch (row.OrderStatus) {
                                case 0:
                                    return "<span style=\"color:orange\">已作废</span>";
                                case 1:
                                    return "<span style=\"color:red\">待处理</span>";
                                case 2:
                                    return "<span style=\"color:#b806a9\">待执行</span>";
                                case 3:
                                    return "<span style=\"color:#2701e9\">执行中</span>";
                                case 4:
                                    return "<span style=\"color:#e90122\">订单完成</span>";
                                default:
                                    return "";
                                    break;
                            }
                        },
                        OrderEnd: function (column, row) {
                            switch (row.OrderStatus) {
                                case 1:
                                    return "<span style=\"color:red\">(预定) </span>" + row.OrderBegin + "至" + row.OrderEnd;
                                case 2:
                                    return "<span style=\"color:red\">(预定) </span>" + row.OrderBegin + "至" + row.OrderEnd;

                                case 3:
                                    return "<span style=\"color:green\">(服务) </span>" + row.OrderBegin + "至" + row.OrderEnd;
                                case 4:
                                    return "<span style=\"color:red\">(服务) </span>" + row.OrderBegin + "至" + row.OrderEnd;
                                default:
                                    return "";
                                    break;
                            }
                        },
                        "OrderCreater": function (column, row) {
                            return row.OrderCreaterName;
                        },
                        "OrderWeihu": function (column, row) {
                            return row.OrderWeihuName;
                        },
                        OrderType: function (column, row) {
                            return GetOptionValue(row.OrderType, "1|月嫂服务,2|育婴师服务,3|会所服务,4|增值产品");
                        },
                        "commands": function (column, row) {
                            if (row.OrderType == 1) {
                                return "<a href='javascript:order_do(\"" + row.OrderCode + "\")'  style=\"color:blue\">处理订单</a>";
                            }
                            if (row.OrderType == 2) {
                                return "<a href='javascript:order_do1(\"" + row.OrderCode + "\")'  style=\"color:blue\">处理订单</a>";
                            }
                            if (row.OrderType == 3) {
                                return "<a href='javascript:order_do2(\"" + row.OrderCode + "\")'  style=\"color:blue\">处理订单</a>";
                            }
                            if (row.OrderType == 4) {
                                return "<a href='javascript:order_do2(\"" + row.OrderCode + "\")'  style=\"color:blue\">处理订单</a>";
                            }
                        }
                    }
                }).on("loaded.rs.jquery.bootgrid", function (e) {
                    //按钮提示
                    $('.tip').tooltip({ placement: "bottom" });
                    //按钮气泡
                    $('.pop').popover({ html: true, trigger: "hover" });
                    //showMsg("数据加载完毕！", "Success");
                });
            }




            //月嫂订单处理界面
            function order_do(order_code) {
                showTopWindow("show_order_do", "/Order/YuesaoOrder/Edit?actionType=Do&order_code=" + order_code, "处理月嫂订单",950,500, function () {

                    var yuesaoorder_form = $(top.window.frames["frm_show_order_do"].document).find("#step4_form");
                    //console.log(yuesaoorder_form);
                    var flag = top.window.document.getElementById("frm_show_order_do").contentWindow.form_valid();
                    if (!flag) {
                        return false;
                    }
                 
                  if (!flag) {
                    return false;
                }
                var data = $(yuesaoorder_form).serialize();
                //console.log(data);

                //alert(data);
                $.ajax({
                    type: "POST",
                    cache: false,
                    url: "/api/YuesaoOrderApi/EditYuesaoOrder?order_code=" + order_code,
                    data: data,
                    dataType: "json",
                    beforeSend: function () {
                        //显示加载中
                        showTopDialog("show_loading", "<div class='dialog_loading'>月嫂订单确认中，请稍后...</div>", "温馨提示", 400, 95);
                    },
                    complete: function () {
                    },
                    success: function (result) {
                        top.dialog.list["show_loading"].close().remove();
                        //toLowerCase报错
                        //var status = result.Status.toLowerCase();
                        var status = result.Status;
                        if (status == true || status == "true" || status == "True") {
                            //刷新数据
                            show_do_order_success();
                            order_grid.bootgrid("reload");
                        } else {
                            showMsg("系统异常，订单确认失败！", "Error");
                        }
                    },
                    error: function () {
                        top.dialog.list["show_loading"].close().remove();
                        showMsg("网络连接错误!", "错误提示", "Error");
                    }
                });


                //必须有这个，阻止刷新
                return false;
           
                },function(){});
            }


            //育婴师订单处理界面
            function order_do1(order_code) {
                showTopWindow("show_order_do", "/Order/YingshiOrder/Edit?actionType=Do&order_code=" + order_code,"处理育婴师订单", 950, 500, function () {

                    var yuesaoorder_form = $(top.window.frames["frm_show_order_do"].document).find("#step4_form");
                    //console.log(yuesaoorder_form);
                    var flag = top.window.document.getElementById("frm_show_order_do").contentWindow.form_valid();
                    if (!flag) {
                        return false;
                    }

                    if (!flag) {
                        return false;
                    }
                    var data = $(yuesaoorder_form).serialize();
                    //console.log(data);

                    //alert(data);
                    $.ajax({
                        type: "POST",
                        cache: false,
                        url: "/api/YingshiOrderApi/EditYuesaoOrder?order_code=" + order_code,
                        data: data,
                        dataType: "json",
                        beforeSend: function () {
                            //显示加载中
                            showTopDialog("show_loading", "<div class='dialog_loading'>月嫂订单确认中，请稍后...</div>", "温馨提示", 400, 95);
                        },
                        complete: function () {
                        },
                        success: function (result) {
                            top.dialog.list["show_loading"].close().remove();
                            //toLowerCase报错
                            //var status = result.Status.toLowerCase();
                            var status = result.Status;
                            if (status == true || status == "true" || status == "True") {
                                //刷新数据
                                show_do_order_success();
                                order_grid.bootgrid("reload");
                            } else {
                                showMsg("系统异常，订单确认失败！", "Error");
                            }
                        },
                        error: function () {
                            top.dialog.list["show_loading"].close().remove();
                            showMsg("网络连接错误!", "错误提示", "Error");
                        }
                    });
                    //必须有这个，阻止刷新
                    return false;
                }, function () { });
            }

            //月子会所订单和增值产品处理界面
            function order_do2(order_code) {
                showTopWindow("show_order_do", "/Order/Corder/EditHuisuoInfo?actionType=Do&order_code=" + order_code, null, 900, 450, function () {

                    var yuesaoorder_form = $(top.window.frames["frm_show_order_do"].document).find("#step4_form");
                    //console.log(yuesaoorder_form);
                    var flag = top.window.document.getElementById("frm_show_order_do").contentWindow.form_valid();
                    if (!flag) {
                        return false;
                    }

                    if (!flag) {
                        return false;
                    }
                    var data = $(yuesaoorder_form).serialize();
                    //console.log(data);

                    //alert(data);
                    $.ajax({
                        type: "POST",
                        cache: false,
                        url: "/api/CorderApi/EditHuisuoInfo?order_code=" + order_code,
                        data: data,
                        dataType: "json",
                        beforeSend: function () {
                            //显示加载中
                            showTopDialog("show_loading", "<div class='dialog_loading'>订单确认中，请稍后...</div>", "温馨提示", 400, 95);
                        },
                        complete: function () {
                        },
                        success: function (result) {
                            top.dialog.list["show_loading"].close().remove();
                            //toLowerCase报错
                            //var status = result.Status.toLowerCase();
                            var status = result.Status;
                            if (status == true || status == "true" || status == "True") {
                                //刷新数据
                                show_do_order_success();
                                order_grid.bootgrid("reload");
                            } else {
                                showMsg("系统异常，订单确认失败！", "Error");
                            }
                        },
                        error: function () {
                            top.dialog.list["show_loading"].close().remove();
                            showMsg("网络连接错误!", "错误提示", "Error");
                        }
                    });
                    //必须有这个，阻止刷新
                    return false;
                }, function () { });
            }
         
            //预定成功
            function show_do_order_success() {
                top.dialog.list["show_order_do"].close().remove();
                var d = top.dialog({
                    id: "show_order_do_success",
                    title: "预定完成",
                    content: "<div class='dialog_ok'>恭喜你，成功确认订单！</div>   ",
                    width: 400,
                    height: 80,
                    okValue: '确定',
                    ok: function () {
                        //关闭添加框
                        //top.dialog.list["show_order_do"].close().remove();
                        //关闭提示框
                        //top.dialog.list["show_order_success"].close().remove();
                        //跳转到客户管理
                        //showTopContentWindow("show_order_success", "/Customer/ClientInfo/List", "客户信息管理", 1000, 500);
                    },
                    cancelValue: '取消',
                    cancel: function () {
                        //关闭添加框
                        //top.dialog.list["show_order_do_success"].close().remove();
                        //关闭提示框
                        //top.dialog.list["show_order_success"].close().remove();
                        //跳转到订单添加
                        //showTopContentWindow("show_add_client", "/Order/YuesaoOrder/AddClient/", "1. 选择订单类型并确认客户信息", 500, 200);
                    }
                });
                d.showModal();
            }

            function order_trash() {
                var ids = get_selected_ids("order_grid_data");
                //console.log(ids);
                if (ids == "") {
                    showTopMsg("请选择你要放入回收站的记录！", "错误提示", "Error");
                    return false;
                }
                //console.log(ids);
                //return false;
                showTopDialog("show_order_trash", "<div class='dialog_confirm'>确认将选中记录放入回收站吗？</div>", "温馨提示", 400, 75, function () {
                    $.ajax({
                        type: "GET",
                        cache: false,
                        url: "/api/OrderApi/UpdateOrderStatusTrash?ids=" + ids + "&status=0",
                        //data: { ids: ids },
                        dataType: "json",
                        beforeSend: function () {
                            //showMsg("添加中，请稍后...");
                        },
                        complete: function () {
                            //d.close().remove();
                        },
                        success: function (result) {
                            //toLowerCase报错
                            //var status = result.Status.toLowerCase();
                            var status = result.Status;
                            if (status == true || status == "true" || status == "True") {
                                //刷新数据
                                order_grid.bootgrid("reload");
                                showMsg("订单放入回收站成功！", "Success");
                            } else {
                                showMsg("系统异常，订单放入回收站失败！", "Error");
                            }
                        },
                        error: function () {
                            showTopMsg("网络连接错误!", "错误提示", "Error");
                        }
                    });
                });
                //必须有这个，阻止刷新
                return false;
            }

        </script>


    
 </head>
    <body>

<div>
    <table id="order_grid_data" class="table table-condensed table-hover table-striped table-bordered" data-selection="true" data-multi-select="true">
        <thead>
            <tr>
	  <th data-column-id="OrderCode" data-header-align="center"  data-formatter="OrderCode" data-order="desc" data-header-css-class="wid140">订单编号</th>
	  <th data-column-id="OrderType" data-header-align="center"  data-formatter="OrderType" data-order="desc">订单类型</th>
	  <th data-column-id="ClientId" data-header-align="center"  data-formatter="ClientId" data-order="desc" data-header-css-class="wid160">客户</th><th data-column-id="OrderEnd" data-header-align="center"  data-formatter="OrderEnd" data-order="desc" data-header-css-class="wid200">服务时间</th>
		  <th data-column-id="OrderStatus" data-header-align="center"  data-formatter="OrderStatus" data-order="desc">订单状态</th>
		  <th data-column-id="OrderPrepaid" data-header-align="center"  data-formatter="OrderPrepaid" data-order="desc">已付金额</th>
		  		  <th data-column-id="OrderDate" data-header-align="center"  data-formatter="OrderDate" data-order="desc">下单日期</th>
		  <th data-column-id="Id" data-type="numeric" data-identifier="true" data-formatter="commands" data-sortable="false">操作</th>
		    </tr>
        </thead>
    </table>
</div>

</body>
</html>


